Skip to content

Check the file version of spec JSON files - #1498

Merged
VisLab merged 2 commits into
hed-standard:mainfrom
VisLab:address_issues
Nov 8, 2026
Merged

VisLab merged 2 commits into
hed-standard:mainfrom
VisLab:address_issues

Conversation

@VisLab

@VisLab VisLab commented Nov 8, 2026

Copy link
Copy Markdown
Member

Specification Appendix A.6.1 (hed-specification #731): a validator must not apply a reserved_tags.json or character_sets.json whose file version major number it does not support. Fixes #1489.

  • reserved_tags.json refreshed verbatim from hed-specification main; it gains specificationVersion and fileVersion.
  • New hed/validator/util/spec_files.py: check_file_version raises HedFileError INVALID_FILE_FORMAT when the version key is missing, is not major.minor.patch, or its major number is not 1.
  • ReservedChecker reads its file through the new load_reserved_file; CharacterSets checks the version before reading the sets.
  • Tests for accepted and refused versions of both files; CHANGELOG.

Specification Appendix A.6.1 (hed-specification hed-standard#731): a validator
must not apply a reserved_tags.json or character_sets.json whose file
version major number it does not support. Fixes hed-standard#1489.

- reserved_tags.json refreshed verbatim from hed-specification main;
  it gains specificationVersion and fileVersion.
- New hed/validator/util/spec_files.py: check_file_version raises
  HedFileError INVALID_FILE_FORMAT when the version key is missing,
  is not major.minor.patch, or its major number is not 1.
- ReservedChecker reads its file through the new load_reserved_file;
  CharacterSets checks the version before reading the sets.
- Tests for accepted and refused versions of both files; CHANGELOG.
@VisLab
VisLab requested a balanced review from Copilot November 8, 2026 21:14
@VisLab VisLab added enhancement New feature or request documentation An error in the documentation or something is missing required-update labels Nov 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The version check accepts a trailing newline, allowing both loaders to apply files with malformed versions instead of raising HedFileError.

1 open issue
What changed in this PR

Adds file-version checks to the specification data loaders, addressing #1489 and the compatibility requirement in Appendix A.6.1.

Changes:

  • Adds a shared check for missing, malformed, or unsupported file versions.
  • Integrates the check into both loaders and refreshes reserved-tag version metadata.
  • Adds version acceptance and rejection tests and documents the behavior.
File Description
tests/​validator/​test_spec_files.py Tests shared version validation and malformed inputs.
tests/​validator/​test_reserved_checker.py Tests reserved-tag metadata and loader version checks.
tests/​validator/​test_character_sets.py Tests character-set version compatibility.
hed/​validator/​util/​spec_files.py Implements the shared file-version check.
hed/​validator/​util/​character_sets.py Checks file compatibility before loading character sets.
hed/​validator/​reserved_checker.py Adds a version-checked reserved-tag loader.
hed/​validator/​data/​reserved_tags.json Adds specification and file version metadata.
CHANGELOG.md Documents the metadata and compatibility checks.

Review effort: Balanced

Comment thread hed/validator/util/spec_files.py Resolved
Address the Copilot review of PR hed-standard#1498: re.match with $ accepted
"1.0.0\n", and \d accepted non-ASCII digits such as U+0661. Use
fullmatch with [0-9], and test both strings as malformed.
@VisLab
VisLab merged commit e1e4d49 into hed-standard:main Nov 8, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation An error in the documentation or something is missing enhancement New feature or request required-update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Read the version fields of reserved_tags.json and character_sets.json

2 participants